﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ELMWCFServiceClass.ELMWCF;

namespace SettingModule.Views.UserInfoSettingView
{
    public partial class CW_ContentTypeDetial : ChildWindow
    {
        public CW_ContentTypeDetial(IUserInfoSettingPresentationModel model,Guid contentId)
        {
            InitializeComponent();
            this.model = model;
            this.DataContext = model;
            ContentId = contentId;
          
        }
    
        private Guid ContentId;
        private IUserInfoSettingPresentationModel model;

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (ContentId != Guid.Empty)
            {
                model.SaveData(ContentId);
                this.DialogResult = true;
                ContentId = Guid.Empty;
            }
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
             ContentId=Guid.Empty;
        }

        private void Add(object sender, RoutedEventArgs e)
        {
            if (lbUnselect.SelectedItem != null)
            {
                model.AddToSelected((ELMField)lbUnselect.SelectedItem);
            }
        }

        private void Del(object sender, RoutedEventArgs e)
        {
            if (lbselect.SelectedItem != null)
            {
                model.RemoveFromSelected((ELMField)lbselect.SelectedItem);
            }
        }

        private void DragDropTarget_Drop(object sender, Microsoft.Windows.DragEventArgs e)
        {

        }

        private void UpClick(object sender, RoutedEventArgs e)
        {
            model.ChangeSelectedDataIndex(-1);
        }

        private void DownClick(object sender, RoutedEventArgs e)
        {
            model.ChangeSelectedDataIndex(1);
        }

        private void lbselect_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (model.SelectedDataWhichIsSelected != null)
            {
                SetPanel.Visibility = Visibility.Visible;
            }
            else
            {
                SetPanel.Visibility = Visibility.Collapsed;
            }
        }
    }
}

